<script type="text/javascript">
    $(function () {
        var data_id = '{{$data_id}}';
        var resource_data_id = '{{$resource_data_id}}';
        console.log(resource_data_id);
        // ajax回填数据及数据ID
        $.ajax({
            url : '/admin/application/collist_datas/datas/'+data_id+'/resources',
            type:'get',
            cache: false,
            dataType:'json',
            async:true,
            success:function(data){
                console.log(data);
                if (data.status) {
                    $(".resource_data_id").empty();// jq写法 清楚地区下拉框的所有内容，然后拼接上从后台取出来的数据
                    $("<option value=''>请选择</option>").appendTo(".resource_data_id");
                    var reasourceData = data.content;
                    for(var i=0;i<reasourceData.length;i++){
                        //获取reasourceData里面的数据，拼接到select上
                        if (reasourceData[i].id == resource_data_id) {
                            $(".resource_data_id").append("<option value='"+reasourceData[i].id+"' selected >"+reasourceData[i].title+"</option>");

                        }else{
                            $(".resource_data_id").append("<option value='"+reasourceData[i].id+"'>"+reasourceData[i].title+"</option>");
                        }
                    }
                } else {
                    // layer.msg(data.content, {
                    //     icon: 5
                    // });
                }

            },
            error: function() {
                layer.msg("异常！");
            }
        });
        // ajax回填range和模板
        var singRange = '{{$range}}';
        var tpl_id = '{{$tpl_id}}';
        $.ajax({
            url : '/admin/entity/column/collists/range/'+singRange+'/resources',
            type:'get',
            cache: false,
            dataType:'json',
            async:true,
            success:function(data){
                console.log(data);
                if (data.status) {
                    $(".tpl_id").empty();// jq写法 清楚地区下拉框的所有内容，然后拼接上从后台取出来的数据
                    $("<option value=''>请选择</option>").appendTo(".tpl_id");
                    var reasourceData = data.content;
                    for(var i=0;i<reasourceData.length;i++){
                        //获取reasourceData里面的数据，拼接到select上
                        if (reasourceData[i].id == tpl_id) {
                            $(".tpl_id").append("<option value='"+reasourceData[i].id+"' selected >"+reasourceData[i].title+"</option>");

                        }else{
                            $(".tpl_id").append("<option value='"+reasourceData[i].id+"'>"+reasourceData[i].title+"</option>");
                        }
                    }
                } else {
                    // layer.msg(data.content, {
                    //     icon: 5
                    // });
                }

            },
            error: function() {
                layer.msg("异常！");
            }
        });

    });

</script>
